//13.罗马数字转整数
//https://leetcode.cn/problems/roman-to-integer/
class Solution {
public:
    int romanToInt(string s) {
        unordered_map<char,int> hash = 
        { {'I',1} , {'V',5} , {'X',10} , {'L',50} , {'C',100} , {'D',500} , {'M',1000} };

        int n = s.size();
        int ret = 0;
        for(int i = 0;i<n;++i)
        {
            if(i+1<n && hash[s[i]] < hash[s[i+1]]) ret -= hash[s[i]];
            else ret += hash[s[i]];
        }
        return ret;
    }
};